<template>
  <div v-if="showgo">
    <img class="back-to-top" src="./back_to_top.png" alt="" @click="gotop()">
    <!-- <van-icon class="back-to-top" name="upgrade" @click="gotop()" size="30px" /> -->
  </div>
</template>

<script>
  export default {
    data() {
      return {
        showgo: false
      }
    },
    methods: {
      gotop() {
        scrollTo(0, 0)
      }
    },
    mounted() {
      var vm = this
      window.onscroll = function() {
        if (document.documentElement.scrollTop > 1000) {
          vm.showgo = true
        } else {
          vm.showgo = false
        }
      }
    }
  }
</script>

<style scoped>
  .back-to-top {
    position: fixed;
    z-index: 9999;
    bottom: 90px;
    right: 40px;
  }
</style>
